﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestModule
{
    /// <summary>
    /// 绘图圆弧单元符号
    /// </summary>
    public class NodeArc : NodeLineSymbol
    {
        /// <summary>
        /// 圆心
        /// </summary>
        private Point _center;
        public Point Center
        {
            get { return _center; }
            set { _center = value; }
        }

        /// <summary>
        /// 半径
        /// </summary>
        private double _radius;
        public double Radius
        {
            get { return _radius; }
            set { _radius = value; }
        }

        /// <summary>
        /// 开始角度
        /// </summary>
        private double _beginAngle;
        public double BeginAngle
        {
            get { return _beginAngle; }
            set { _beginAngle = value; }
        }

        /// <summary>
        /// 结束角度
        /// </summary>
        private double _endAngle;
        public double EndAngle
        {
            get { return _endAngle; }
            set { _endAngle = value; }
        }

        /// <summary>
        /// 圆弧方向
        /// </summary>
        private int _Arcdir;
        public int Arcdir
        {
            get { return _Arcdir; }
            set { _Arcdir = value; }
        }

        /// <summary>
        /// 画圆
        /// </summary>
        /// <param name="img"></param>
        public override void Draw(Graphics img)
        {
            if (BNo)
                img.DrawString(this.Index.ToString(), new Font("Verdana", 10), new SolidBrush(Color.Tomato), this.Center);

            if (BRemark)
                img.DrawString(this.Remark, new Font("Verdana", 10), new SolidBrush(Color.Tomato), this.Center);

            Pen pen = new Pen(base.PenColor, base.Width);
            if (base.BDirection)
            {
                AdjustableArrowCap lineCap = new System.Drawing.Drawing2D.AdjustableArrowCap(10, 15, true);
                pen.CustomEndCap = lineCap;
            }

            img.DrawArc(pen, 
                new Rectangle(this.Center.X  - Convert.ToInt16(this.Radius), 
                    this.Center.Y - Convert.ToInt16(this.Radius),
                    Convert.ToInt16( 2 * this.Radius),
                   Convert.ToInt16(2 * this.Radius)),
                Convert.ToSingle(this.BeginAngle), 
                Convert.ToSingle(this.Arcdir * Math.Abs(this.BeginAngle - this.EndAngle)));
        }
    }
}
